 package client;

 import constants.GameConstants;
 import java.io.Serializable;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import server.life.MapleLifeFactory;
 import server.quest.MapleQuest;

 public final class MapleQuestStatus
   implements Serializable
 {
   private static final long serialVersionUID = 91795419934134L;
   private transient MapleQuest quest;
   private byte status;
/*  17 */   private Map<Integer, Integer> killedMobs = null;
   private int npc;
   private long completionTime;
/*  20 */   private int forfeited = 0;


   private String customData;



   public MapleQuestStatus() {}


   public MapleQuestStatus(MapleQuest quest, int status) {
/*  31 */     this.quest = quest;
/*  32 */     setStatus((byte)status);
/*  33 */     this.completionTime = System.currentTimeMillis();
/*  34 */     if (status == 1 && 
/*  35 */       !quest.getRelevantMobs().isEmpty()) {
/*  36 */       registerMobs();
     }
   }


   public MapleQuestStatus(MapleQuest quest, byte status, int npc) {
/*  42 */     this.quest = quest;
/*  43 */     setStatus(status);
/*  44 */     setNpc(npc);
/*  45 */     this.completionTime = System.currentTimeMillis();
/*  46 */     if (status == 1 && 
/*  47 */       !quest.getRelevantMobs().isEmpty()) {
/*  48 */       registerMobs();
     }
   }


   public MapleQuest getQuest() {
/*  54 */     return this.quest;
   }

   public void setQuest(int qid) {
/*  58 */     this.quest = MapleQuest.getInstance(qid);
   }

   public byte getStatus() {
/*  62 */     return this.status;
   }

   public void setStatus(byte status) {
/*  66 */     this.status = status;
   }

   public int getNpc() {
/*  70 */     return this.npc;
   }

   public void setNpc(int npc) {
/*  74 */     this.npc = npc;
   }

   public boolean isCustom() {
/*  78 */     return GameConstants.isCustomQuest(this.quest.getId());
   }

   private void registerMobs() {
/*  82 */     this.killedMobs = new LinkedHashMap<>();
/*  83 */     for (Iterator<Integer> iterator = this.quest.getRelevantMobs().keySet().iterator(); iterator.hasNext(); ) { int i = ((Integer)iterator.next()).intValue();
/*  84 */       this.killedMobs.put(Integer.valueOf(i), Integer.valueOf(0)); }

   }

   private int maxMob(int mobid) {
/*  89 */     for (Map.Entry<Integer, Integer> qs : (Iterable<Map.Entry<Integer, Integer>>)this.quest.getRelevantMobs().entrySet()) {
/*  90 */       if (((Integer)qs.getKey()).intValue() == mobid) {
/*  91 */         return ((Integer)qs.getValue()).intValue();
       }
     }
/*  94 */     return 0;
   }

   public boolean mobKilled(int id, int skillID) {
/*  98 */     if (this.quest != null && this.quest.getSkillID() > 0 && 
/*  99 */       this.quest.getSkillID() != skillID) {
/* 100 */       return false;
     }

/* 103 */     Integer mob = this.killedMobs.get(Integer.valueOf(id));
/* 104 */     if (mob != null) {
/* 105 */       int mo = maxMob(id);
/* 106 */       if (mob.intValue() >= mo) {
/* 107 */         return false;
       }
/* 109 */       this.killedMobs.put(Integer.valueOf(id), Integer.valueOf(Math.min(mob.intValue() + 1, mo)));
/* 110 */       return true;
     }
/* 112 */     for (Map.Entry<Integer, Integer> mo : this.killedMobs.entrySet()) {
/* 113 */       if (MapleLifeFactory.exitsQuestCount(((Integer)mo.getKey()).intValue(), id)) {
/* 114 */         int mobb = maxMob(((Integer)mo.getKey()).intValue());
/* 115 */         if (((Integer)mo.getValue()).intValue() >= mobb) {
/* 116 */           return false;
         }
/* 118 */         this.killedMobs.put(mo.getKey(), Integer.valueOf(Math.min(((Integer)mo.getValue()).intValue() + 1, mobb)));
/* 119 */         return true;
       }
     }
/* 122 */     return false;
   }

   public void setMobKills(int id, int count) {
/* 126 */     if (this.killedMobs == null) {
/* 127 */       registerMobs();
     }
/* 129 */     this.killedMobs.put(Integer.valueOf(id), Integer.valueOf(count));
   }

   public boolean hasMobKills() {
/* 133 */     return (this.killedMobs != null && this.killedMobs.size() > 0);
   }

   public int getMobKills(int id) {
/* 137 */     Integer mob = this.killedMobs.get(Integer.valueOf(id));
/* 138 */     if (mob == null) {
/* 139 */       return 0;
     }
/* 141 */     return mob.intValue();
   }

   public Map<Integer, Integer> getMobKills() {
/* 145 */     return this.killedMobs;
   }

   public long getCompletionTime() {
/* 149 */     return this.completionTime;
   }

   public void setCompletionTime(long completionTime) {
/* 153 */     this.completionTime = completionTime;
   }

   public int getForfeited() {
/* 157 */     return this.forfeited;
   }

   public void setForfeited(int forfeited) {
/* 161 */     if (forfeited >= this.forfeited) {
/* 162 */       this.forfeited = forfeited;
     } else {
/* 164 */       throw new IllegalArgumentException("Can't set forfeits to something lower than before.");
     }
   }

   public String getCustomData() {
/* 169 */     return this.customData;
   }

   public void setCustomData(String customData) {
/* 173 */     this.customData = customData;
   }




   public boolean isDailyQuest() {
/* 180 */     switch (this.quest.getId()) {
       case 11463:
       case 11464:
       case 11465:
       case 11468:
/* 185 */         return true;
     }
/* 187 */     return false;
   }
 }


/* Location:              C:\PGX\Server.jar!\client\MapleQuestStatus.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */